#ifndef __HTTPRESPONSE_H__
#define __HTTPRESPONSE_H__

#include <string>

namespace tiny_muduo
{
    static const std::string CRLF = "\r\n";
    
    enum HttpStatusCode
    {
        k100Continue            = 100,
        k200OK                  = 200,
        k400BadRequest          = 400,
        k403Forbidden           = 403,
        k404NotFound            = 404,
        k500InternalServerErrno = 500,
    };

    class Buffer;

    class HttpResponse
    {
    public:
        HttpResponse(bool close_connection = false) : type_("text/plain"),
                                                close_connection_(close_connection) {}
        ~HttpResponse() = default;

        void SetStatusCode(HttpStatusCode status_code) { status_code_ = status_code; }
        void SetStatusMessage(const std::string_view status_message) { status_message_ = status_message; }
        void SetCloseConnection(bool close_connection) { close_connection_ = close_connection; }

        void SetBodyType(const std::string_view type) { type_ = type; }
        void SetBodyType(const char* type) { type_ = type; }
        void SetBody(const std::string_view body) { body_ = body; }
        void SetBody(const char* body) { body_ = body; }
        void AppendToBuffer(Buffer* buffer);

        bool CloseConnection() { return close_connection_; }

    private:
        static const std::string server_name_;
        HttpStatusCode status_code_;
        std::string status_message_;
        std::string headers_;
        std::string body_;
        std::string type_;
        bool close_connection_;
    };
}

#endif
